const path = require("path");

const { normalizePath } = require("./utils");
const { resolvePlugins } = require("./plguins");

async function resolveConfig() {
  const root = process.cwd();
  const cacheDir = normalizePath(path.resolve(`node_modules/.myvite`));

  const config = {
    root,
    cacheDir, // 存放预编译后的文件 metadata 等
  };

  const plugins = await resolvePlugins(config);
  config.plugins = plugins;

  return config;
}

module.exports = resolveConfig;
